//
//  GetLoginButton.m
//  ImageReplacer
//
//  Created by Tyler Powell on 5/7/12.
//  Copyright (c) 2012 Georgia Institute of Technology. All rights reserved.
//

#import "GetLoginButton.h"

@implementation GetLoginButton
@synthesize loginField;
@synthesize writer;
- (IBAction)openFile:(id)pId;
{
	NSOpenPanel* openDlg = [NSOpenPanel openPanel];
	//NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
	[openDlg setCanChooseFiles:YES];
	[openDlg setCanChooseDirectories:YES];
    //[openDlg setDirectoryURL:[NSURL fileURLWithPath:[@"file://" stringByAppendingString:[@"~/Applications" stringByExpandingTildeInPath]] isDirectory:YES]];
    //NSLog([[openDlg directoryURL]path]);
    NSArray* fileTypes = [NSArray arrayWithObject:@"swf"];
	if([openDlg runModalForDirectory:nil file:nil types:fileTypes] == NSOKButton)
	{
        
		NSArray* files = [openDlg filenames];
		for(int i=0; i<[files count]; i++)
		{
			NSString* fileName = [files objectAtIndex:i];
			//writeToFileAtIndex(@"options.txt", fileName,6);
            [writer replaceOptionAtIndex:6 withOption:fileName];
			//[workspace openFile:fileName];
		}
		
	}
    [loginField changeTextFieldText:self];
}
@end
